package com.yaoli.ajob;

/**
 * Created by siemens on 4/5/2017.
 */
public class _537_ComplexNumberMultiplication {
    /**
     * 注意正则表达式
     * @param a
     * @param b
     * @return
     */
    public String complexNumberMultiply(String a, String b) {
        String seta [] = a.split("\\+");
        String setb [] = b.split("\\+");

        Integer a_a = Integer.valueOf(seta[0]);
        Integer a_b = Integer.valueOf(seta[1].substring(0,seta[1].length() - 1));


        Integer b_a = Integer.valueOf(setb[0]);
        Integer b_b = Integer.valueOf(setb[1].substring(0,setb[1].length()  - 1));

        Integer c = a_a * b_a;
        Integer d = a_a * b_b;

        Integer e = a_b * b_a;
        Integer f = a_b * b_b;

        Integer g = d + e;

        return String.valueOf(c+f*(-1))+"+"+String.valueOf(g)+"i";
    }
}
